﻿using System;
using System.Windows.Forms;

namespace Odin.Execution.Client
{
	public partial class BrowserForm : Form
	{
		public BrowserForm()
		{
			InitializeComponent();
		}

		public event EventHandler DocumentCompleted = (s, e) => { };

		private string _url;

		public void Navigate(string url)
		{
			_url = url;
			_webBrowser.Navigate(url);
			_webBrowser.DocumentCompleted += WebBrowserDocumentCompleted;
		}

		private void WebBrowserDocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
		{
			if (e.Url.Equals(_url))
			{
				DocumentCompleted(sender, new EventArgs());
			}
		}
	}
}
